package com.fudian.spark_platform.DBConnector
import org.apache.log4j.{Logger,Level}
import org.apache.spark.{SparkContext, SparkConf}


class DBBase(s : DBBase) {

    var conf : SparkConf = null
    var spark : SparkContext = null

    var _appName : String = "孚典spark数据分析平台"
    var _SparkMaster : String = "local[*]"

    def this() = {
        this(null)
        init_conf()
    }

    def setConf(key: String,value: String) = this.conf.set(key,value)

    def init_conf() = this.conf= new SparkConf().setAppName(this._appName).setMaster(this._SparkMaster)

    def setLogLevel(level:String = "ERROR"): Unit = {
        Logger.getLogger("org").setLevel(Level.toLevel(level))
    }

    def sc:SparkContext = {
        if(this.spark eq null){
            this.spark = new SparkContext(this.conf)
        }
        this.spark
    }
}


